<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>forin.html</title>
<script>
	function chk(a,b){
		if(a>b) return -1;
		else if(a==b) return 0;
		else if(a<b) return 1;
		
	}




	//json패턴으로 배열선언
	var array=['백두산','금강산','한라산','지리산','치악산','도봉산'];
	var river=['한강','두만강','낙동강','금강','해금강','똥강'];
	
	
	for(var x in array){
		document.write(x);
		document.write(array[x]);
		document.write("<br/>");	
	}
	
	//배열합치기
	var allArray =array.concat(river);
	document.write("배열을 하나의 배열로: "+allArray);
	document.write("<p/>");	
	
	//배열 뒤짚기
	document.write("<p/>"+allArray.reverse());
	document.write("<p/>");	
	
	//join문자열
	document.write("<b>JOIN</b>"+allArray.join("-->"));
	document.write("<p/>");	
	
	//sort
	document.write("<b>Sort</b>"+allArray.sort("chk"));
	document.write("<p/>");	

</script>


</head>
<body>

</body>
</html>